// Copyright 2010 Alexandre Tristan St-Cyr <tristan.stcyr@gmail.com>

package com.codeplex.loadjava;

import com.codeplex.loadjava.model.ClassDefinition;
import com.codeplex.loadjava.model.Field;
import com.codeplex.loadjava.model.FieldDefinition;
import com.codeplex.loadjava.model.FieldReference;
import com.codeplex.loadjava.model.InterfaceImplementation;
import com.codeplex.loadjava.model.JavaClass;
import com.codeplex.loadjava.model.Method;
import com.codeplex.loadjava.model.MethodDefinition;
import com.codeplex.loadjava.model.MethodException;
import com.codeplex.loadjava.model.MethodInvocation;
import com.codeplex.loadjava.model.MethodParameter;
import com.codeplex.loadjava.model.TypeReference;

public class JavaModelCounterVisitor implements IJavaModelVisitor {

	//private static final Logger logger = Logger.getLogger(JavaModelCounterVisitor.class.getCanonicalName());
	
	private long classCount;
	
	private long typeCount;
	
	private long methodCount;
	
	private long fieldCount;
	
	private long classDefinitionCount;
	
	private long methodDefinitionCount;
	
	private long fieldDefinitionCount;
	
	private long fieldReferenceCount;
	
	private long interfaceImplementationCount;
	
	private long methodExceptionCount;

	private long methodInvocationCount;

	private long methodParameterCount;
	
	public long getClassCount()
	{
		return classCount;
	}
	
	public long getTypeCount()
	{
		return typeCount;
	}
	
	public long getMethodCount()
	{
		return methodCount;
	}
	
	public long getFieldCount()
	{
		return fieldCount;
	}

	@Override
	public void visitClassFile(String relativePath) {
		//logger.log(Level.INFO, "Counting entities in "+relativePath+"...");
	}

	@Override
	public void endVisitClassFile(String relativePath) {
		//logger.log(Level.INFO, "Done counting entities in "+relativePath+"...");
	}

	@Override
	public void visitField(Field field) {
		this.fieldCount++;
	}

	@Override
	public void visitMethod(Method method) {
		this.methodCount++;
	}

	@Override
	public void visitClass(JavaClass javaClass) {
		this.classCount++;
	}

	@Override
	public void visitType(TypeReference typeReference) {
		this.typeCount++;
	}

	@Override
	public void visitFieldDefinition(FieldDefinition fieldDefinition) {
		this.fieldDefinitionCount++;
	}
	
	@Override
	public void visitMethodDefinition(MethodDefinition methodDefinition) {
		this.methodDefinitionCount++;
	}
	
	@Override
	public void visitMethodException(MethodException methodException) {
		this.methodExceptionCount++;
	}
	@Override
	public void visitClassDefinition(ClassDefinition classDefinition) {
		this.classDefinitionCount++;
	}
	@Override
	public void visitFieldReference(FieldReference fieldReference) {
		this.fieldReferenceCount++;
	}
	
	@Override
	public void visitMethodInvocation(MethodInvocation methodInvocation) {
		this.methodInvocationCount++;
	}
	
	@Override
	public void visitInterfaceImplementations(InterfaceImplementation interfaceImplementation) {
		this.interfaceImplementationCount++;
	}
	
	@Override
	public void visitMethodParameter(MethodParameter parameter) {
		this.methodParameterCount++;
	}

	public long getClassDefinitionCount() {
		return this.classDefinitionCount;
	}

	public long getMethodDefinitionCount() {
		return this.methodDefinitionCount;
	}

	public long getFieldDefinitionCount() {
		return this.fieldDefinitionCount;
	}

	public long getFieldReferenceCount() {
		return this.fieldReferenceCount;
	}

	public long getInterfaceImplementationCount() {
		return this.interfaceImplementationCount;
	}

	public long getMethodExceptionCount() {
		return this.methodExceptionCount;
	}
	
	public long getMethodInvocationCount()
	{
		return this.methodInvocationCount;
	}
	
	public long getMethodParameter()
	{
		return this.methodParameterCount;
	}
}
